'use strict';
const base = require('./base');
const moment = require('moment');

module.exports = app => {
    const { STRING, INTEGER, DATE } = app.Sequelize;

    const Maintain = app.model.define('maintain',
        Object.assign(base(app), {
            num: { type: STRING, primaryKey: true},
            equip_num: STRING,
            name: { type: STRING},
            report_time: {
                type: DATE,
                defaultValue: () => {
                    return moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
                },
                get() {
                    return moment(this.getDataValue('report_time')).format('YYYY-MM-DD HH:mm:ss');
                },
            },
            report_name: STRING,
            equip_status: STRING,
            fault_type: STRING,
            fault_level: STRING,
            error: STRING,
            position: STRING(32),
            status: STRING,
            handler: STRING,
            // handle_time: {
            //     type: DATE,
            //     defaultValue: () => {
            //         return moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
            //     },
            //     get() {
            //         return moment(this.getDataValue('handle_time')).format('YYYY-MM-DD HH:mm:ss');
            //     },
            // },
        }));
    return Maintain;
};
